/**
 * Copyright 2013 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.viettel.core.entities.cms;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import com.viettel.core.enumtype.MediaStatus;

/**
 *  TABLE TO BAO
 *  @author: ToanTM1
 *  @version: 2.1
 *  @since: 27-02-2014 - 11:05:15
 */
@Entity
@Table(name = "MEDIA")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name = "SEQ_STORE", sequenceName = "MEDIA_SEQ", allocationSize = 1)
public class Media  implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6057555726316816421L;

	/**
	 * ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
	@Column(name = "ID")
	private Integer id;
	
	/**
	 * MA TO BAO
	 */
	@Basic
	@Column(name = "CODE", length = 20)
	private String code;
	
	/**
	 * TEN TO BAO
	 */
	@Basic
	@Column(name = "NAME", length = 200)
	private String name;
	
	/**
	 * TEN TO BAO KHONG DAU
	 */
	@Basic
	@Column(name = "NAME_TEXT", length = 200)
	private String nameText;
	
	/**
	 * DIA CHI TO BAO
	 */
	@Basic
	@Column(name = "ADDRESS", length = 200)
	private String address;
	
	/**
	 * DIA CHI TO BAO KHONG DAU
	 */
	@Basic
	@Column(name = "ADDRESS_TEXT", length = 200)
	private String addressText;
	
	/**
	 * AVATAR DAY DU
	 */
	@Basic
	@Column(name = "AVATAR_URL", length = 512)
	private String avatarUrl;
	
	/**
	 * AVATAR DA DROP
	 */
	@Basic
	@Column(name = "AVATAR_THUMB", length = 512)
	private String avatarThumb;
	
	/**
	 * MO TA 
	 */
	@Basic
	@Column(name = "DESCRIPTION", length = 2000)
	private String description;
	
	
	/**
	 * TRANG THAI TO BAO
	 */
	@Basic
	@Column(name = "STATUS", columnDefinition = "NUMBER(1,0)", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.MediaStatus"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="MEDIA_STATUSX")
	private MediaStatus status;
	
	/**
	 * QUAN/HUYEM
	 */
	@ManyToOne(targetEntity = District.class)
	@JoinColumn(name = "DISTRICT_ID", referencedColumnName = "id")
	@ForeignKey(name = "MEDIA_DISTRICT_FK")
	private District district;

	/**
	 * THANH PHO/TINH
	 */
	@ManyToOne(targetEntity = Province.class)
	@JoinColumn(name = "PROVINCE_ID", referencedColumnName = "id")
	@ForeignKey(name = "MEDIA_PROVINCE_FK")
	private Province province;

	/**
	 * PHUONG
	 */
	@ManyToOne(targetEntity = Ward.class)
	@JoinColumn(name = "WARD_ID", referencedColumnName = "id")
	@ForeignKey(name = "MEDIA_WARD_FK")
	private Ward ward;
	
	/**
	 * USER TAO
	 */
	@ManyToOne(targetEntity = CmsUser.class)
	@JoinColumn(name = "CMS_USER_ID", referencedColumnName = "id")
	@ForeignKey(name = "MEDIA_CMS_USER_FK")
	private CmsUser cmsUser;
	
	/**
	 * THOI GIAN TAO
	 */
	@Basic
	@Column(name = "CREATED_TIME", columnDefinition = "timestamp(9) default systimestamp", insertable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdTime;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNameText() {
		return nameText;
	}

	public void setNameText(String nameText) {
		this.nameText = nameText;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getAddressText() {
		return addressText;
	}

	public void setAddressText(String addressText) {
		this.addressText = addressText;
	}

	public String getAvatarUrl() {
		return avatarUrl;
	}

	public void setAvatarUrl(String avatarUrl) {
		this.avatarUrl = avatarUrl;
	}

	public String getAvatarThumb() {
		return avatarThumb;
	}

	public void setAvatarThumb(String avatarThumb) {
		this.avatarThumb = avatarThumb;
	}

	public MediaStatus getStatus() {
		return status;
	}

	public void setStatus(MediaStatus status) {
		this.status = status;
	}

	public District getDistrict() {
		return district;
	}

	public void setDistrict(District district) {
		this.district = district;
	}

	public Province getProvince() {
		return province;
	}

	public void setProvince(Province province) {
		this.province = province;
	}

	public Ward getWard() {
		return ward;
	}

	public void setWard(Ward ward) {
		this.ward = ward;
	}


	public Date getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	public CmsUser getCmsUser() {
		return cmsUser;
	}

	public void setCmsUser(CmsUser cmsUser) {
		this.cmsUser = cmsUser;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}


}
